
'use strict'

const { Sequelize, DBPoolUser } = require('./mysqldb')

const UserInfo = function() {
  const tbl = DBPoolUser.define(
    'user_info',
    {
      uid: {
        type: Sequelize.BIGINT,
        allowNull: false,
        defaultValue: 0
      },
      machine_id: {
        type: Sequelize.STRING,
        allowNull: false,
        defaultValue: '',
        length: 255
      },
      open_id: {
        type: Sequelize.STRING,
        allowNull: false,
        defaultValue: '',
        length: 32
      },
      nickname: {
        type: Sequelize.STRING,
        allowNull: false,
        defaultValue: '',
        length: 32
      },
      avatar: {
        type: Sequelize.STRING,
        allowNull: false,
        defaultValue: '',
        length: 32
      },
      sex: {
        type: Sequelize.TINYINT,
        allowNull: false,
        defaultValue: 0
      },
      country: {
        type: Sequelize.STRING,
        allowNull: false,
        defaultValue: ''
      },
      province: {
        type: Sequelize.STRING,
        allowNull: false,
        defaultValue: ''
      },
      city: {
        type: Sequelize.STRING,
        allowNull: false,
        defaultValue: ''
      },
      user_nickname: {
        type: Sequelize.STRING,
        allowNull: false,
        defaultValue: ''
      },
      user_avatar: {
        type: Sequelize.STRING,
        allowNull: false,
        defaultValue: ''
      },
      user_sex: {
        type: Sequelize.TINYINT,
        allowNull: false,
        defaultValue: 0
      },
      user_birth: {
        type: Sequelize.INTEGER,
        allowNull: false,
        defaultValue: ''
      },
      user_country: {
        type: Sequelize.STRING,
        allowNull: false,
        defaultValue: ''
      },
      user_province: {
        type: Sequelize.STRING,
        allowNull: false,
        defaultValue: ''
      },
      user_city: {
        type: Sequelize.STRING,
        allowNull: false,
        defaultValue: ''
      },
      user_sign: {
        type: Sequelize.STRING,
        allowNull: false,
        defaultValue: ''
      },
      open_productions: {
        type: Sequelize.TINYINT,
        allowNull: false,
        defaultValue: 0
      },
      online_time: {
        type: Sequelize.BIGINT,
        allowNull: false,
        defaultValue: 0
      },
      ext_info: {
        type: Sequelize.STRING,
        allowNull: false,
        defaultValue: '',
        length: 5120
      },
      is_admin: {
        type: Sequelize.BOOLEAN,
        allowNull: false,
        defaultValue: false
      }
    },
    {
      tableName: 'user_info',
      timestamps: true
    }
  )

  tbl.removeAttribute('id')
  return tbl
}

const TableUserInfo = new UserInfo()

module.exports = {
  TableUserInfo
}
